<%@page import="java.math.BigDecimal"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@page import="bit.util.ConnectionContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="reqCharEnc.jsp" %>
<%@ include file="preventCache.jsp" %>
<%
// Connection
Connection conn = ConnectionContext.getConnection();
// SQL Query
String sql = "SELECT idx, login_id, name FROM member_info";
// prepare statement
PreparedStatement pstmt = conn.prepareStatement(sql);
// execute
ResultSet rs = pstmt.executeQuery();
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>회원 목록 조회</title>
<link rel="stylesheet"
	type="text/css"
	href="<%= application.getContextPath() %>/style/main.css" />
</head>
<body>
	
	<table>
		<tr>
			<th>No</th>
			<th>ID</th>
			<th>이름</th>
			<th>&nbsp;</th>
		</tr>
<%
int count = 0;
while (rs.next()) {
	count ++;
	BigDecimal idx = rs.getBigDecimal("idx");
	String loginId = rs.getString("login_id");
	String name = rs.getString("name");
%>
		<tr>
			<td><%= idx %></td>
			<td><%= loginId %></td>
			<td><%= name %></td>
			<td align="center">
				<input type="button" value="상세조회" onclick="location.href='member.jsp?idx=<%= idx %>';" />
				<input type="button" value="삭제" onclick="if(confirm('[<%= name %>] 회원정보를 삭제하시겠습니까?')){location.href='delete.jsp?idx=<%= idx %>';}" />
			</td>
		</tr>
<%
}
%>
<%
if (count < 1) {
%>
		<tr>
			<td colspan="5" align="center" class="bgGray">등록된 회원이 없습니다.</td>
		</tr>
<%
}
%>
	</table>
	
	<br/>
	
	<input type="button" value="회원 등록" onclick="location.href='member_add.html';" />
	
</body>
</html>